
#include <BMoveChannel>
#include <BScaleChannel>
#include <BRotateChannel>

#include "member_BChannel.h"
#include "member_BMoveChannel.h"
#include "member_BScaleChannel.h"
#include "member_BRotateChannel.h"

using namespace BWE;

member_BChannel::member_BChannel(BChannel* channel)
{
	boss = channel;
	lerp = Lerp_None;
	target = 0;
	animation = 0;
}
member_BChannel::~member_BChannel()
{

}

void member_BChannel::freshSampler()
{
	BMoveChannel* moveChannel = dynamic_cast<BMoveChannel*>(boss);
	if (moveChannel)
	{
		movechannel_member(moveChannel)->sampler = 0;
		if (lerp == Lerp_Step)
			movechannel_member(moveChannel)->sampler = new BStepSampler<BVector>();
		else if (lerp == Lerp_Linear)
			movechannel_member(moveChannel)->sampler = new BLinearSampler<BVector>();
		else if (lerp == Lerp_QuadBezier)
			movechannel_member(moveChannel)->sampler = new BQuadBezierSampler<BVector>();
		else if (lerp == Lerp_CubicBezier)
			movechannel_member(moveChannel)->sampler = new BCubicBezierSampler<BVector>();
	}
	BScaleChannel* scaleChannel = dynamic_cast<BScaleChannel*>(boss);
	if (scaleChannel)
	{
		scalechannel_member(scaleChannel)->sampler = 0;
		if (lerp == Lerp_Step)
			scalechannel_member(scaleChannel)->sampler = new BStepSampler<BVector>();
		else if (lerp == Lerp_Linear)
			scalechannel_member(scaleChannel)->sampler = new BLinearSampler<BVector>();
		else if (lerp == Lerp_QuadBezier)
			scalechannel_member(scaleChannel)->sampler = new BQuadBezierSampler<BVector>();
		else if (lerp == Lerp_CubicBezier)
			scalechannel_member(scaleChannel)->sampler = new BCubicBezierSampler<BVector>();
	}
	BRotateChannel* rotateChannel = dynamic_cast<BRotateChannel*>(boss);
	if (rotateChannel)
	{
		rotatechannel_member(rotateChannel)->sampler = 0;
		if (lerp == Lerp_Step)
			rotatechannel_member(rotateChannel)->sampler = new BStepSampler<BQuater>();
		else if (lerp == Lerp_Linear)
			rotatechannel_member(rotateChannel)->sampler = new BLinearSampler<BQuater>();
		else if (lerp == Lerp_QuadBezier)
			rotatechannel_member(rotateChannel)->sampler = new BQuadBezierSampler<BQuater>();
		else if (lerp == Lerp_CubicBezier)
			rotatechannel_member(rotateChannel)->sampler = new BCubicBezierSampler<BQuater>();
	}
}
